package com.zxl.exception;

import com.zxl.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @packageName com.zxl.exception
 * @ClassName
 * @Author zxl
 * @Description //TODO
 * @date
 **/
@ControllerAdvice
@Component
@Slf4j
public class ExceptionManager {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R systemException(Exception e){
        log.error(e.getMessage());
        return R.error(e.getMessage());
    }

    @ExceptionHandler(MyException.class)
    @ResponseBody
    public R businessException(MyException e){
        log.error(e.getMessage());
        return R.error(e.getMessage());
    }
}
